#include <bits/stdc++.h>
#define int __int128
using namespace std;

int t,n,m,L,maxv,ansl,d[100010],v[100010],a[100010],p[100010];
bitset<3010>rcd[3010],ans;

inline int read(){
	int s=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-')f^=1;
		c=getchar();
	}
	while(isdigit(c)){
		s=(s<<1)+(s<<3)+(c^48);
		c=getchar();
	}
	return f==0?s:-s;
}

void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10|48);
}

void dfs(int step,int depth,bitset<3010>s){
	if(depth>=ansl||step>m+1)return;
	if(s==ans){
		ansl=depth;
		return;
	}
	dfs(step+1,depth,s);
	dfs(step+1,depth+1,s|rcd[step]);
}


signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	t=read();
	while(t--){
		bool fff=1;
		ansl=LONG_LONG_MAX;
		n=read(),m=read(),L=read(),maxv=read();
		ans=0;
		memset(rcd,0,sizeof(rcd));
		for(register int i=1;i<=n;++i){
			d[i]=read(),v[i]=read(),a[i]=read();
			if(a[i]!=0)fff=0;
		}
		for(register int i=1;i<=m;++i)
			p[i]=read();
		if(fff){
			ansl=0;
			for(register int i=1;i<=n;++i)
				if(v[i]>maxv&&d[i]<=p[m])++ansl;
			write(ansl);
			putchar(' ');
			write(ansl==0?m:m-1);
			puts("");
			continue;
		}
		for(register int i=1;i<=n;++i){
			for(register int j=1;j<=m;++j){
				if(p[j]<d[i])continue;
				if(a[i]==0&&v[i]>maxv)rcd[j][i]=1;
				else if(a[i]!=0){
					register int s=p[j]-d[i];
					if(v[i]*v[i]+2*a[i]*s>maxv*maxv)rcd[j][i]=1;
				}
			}
		}
		for(register int i=1;i<=m;++i)
			ans|=rcd[i];
		register int cnt=0;
		for(register int i=1;i<=m;++i)
			cnt+=ans[i];
		write(cnt);
		putchar(' ');
		dfs(1,0,rcd[0]);
		write(m-ansl);
		puts("");

	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
